package com.ygqh.baby.po;

import com.ygqh.baby.ao.CheckStatus;
import com.ygqh.baby.ao.DataStatus;
import com.ygqh.baby.ao.UserType;
import com.ygqh.baby.utils.DateConvertUtils;

import java.math.BigDecimal;
import java.util.Date;

public class YgAgent implements Cloneable {
	private Long id;

	private Long userId;

	private UserType userType;

	private String telPhone;

	private String trueName;

	private String identityCard;

	private String email;

	private String address;

	private String childAge;

	private String fromChannel;

	private String advantage;

	private String suggest;

	private DataStatus status;

	private CheckStatus checkStatus;

	private Date createTime;

	private String checkRemark;

	private String checkBy;

	private Date checkTime;

	private String cancelBy;

	private Date cancelTime;

	private Date updateTime;

	private String updateBy;

	private String platformNo;

    private Long levelId;

    private String remark;

	private YgUser ygUser;

	// ===========

	private YgAgentLevel agentLevel;

	public String getPassTimeMonthStr() {
		if (checkStatus != null && checkStatus.equals(CheckStatus.Pass) && checkTime != null) {
			return DateConvertUtils.format(checkTime, "yyyy-MM");
		}
		return null;

	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public String getTelPhone() {
		return telPhone;
	}

	public void setTelPhone(String telPhone) {
		this.telPhone = telPhone == null ? null : telPhone.trim();
	}

	public String getTrueName() {
		return trueName;
	}

	public void setTrueName(String trueName) {
		this.trueName = trueName == null ? null : trueName.trim();
	}

	public String getIdentityCard() {
		return identityCard;
	}

	public void setIdentityCard(String identityCard) {
		this.identityCard = identityCard == null ? null : identityCard.trim();
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email == null ? null : email.trim();
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address == null ? null : address.trim();
	}

	public String getChildAge() {
		return childAge;
	}

	public void setChildAge(String childAge) {
		this.childAge = childAge == null ? null : childAge.trim();
	}

	public String getFromChannel() {
		return fromChannel;
	}

	public void setFromChannel(String fromChannel) {
		this.fromChannel = fromChannel == null ? null : fromChannel.trim();
	}

	public String getAdvantage() {
		return advantage;
	}

	public void setAdvantage(String advantage) {
		this.advantage = advantage == null ? null : advantage.trim();
	}

	public String getSuggest() {
		return suggest;
	}

	public void setSuggest(String suggest) {
		this.suggest = suggest == null ? null : suggest.trim();
	}

	public DataStatus getStatus() {
		return status;
	}

	public void setStatus(DataStatus status) {
		this.status = status;
	}

	public CheckStatus getCheckStatus() {
		return checkStatus;
	}

	public void setCheckStatus(CheckStatus checkStatus) {
		this.checkStatus = checkStatus;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getCheckRemark() {
		return checkRemark;
	}

	public void setCheckRemark(String checkRemark) {
		this.checkRemark = checkRemark == null ? null : checkRemark.trim();
	}

	public String getCheckBy() {
		return checkBy;
	}

	public void setCheckBy(String checkBy) {
		this.checkBy = checkBy == null ? null : checkBy.trim();
	}

	public Date getCheckTime() {
		return checkTime;
	}

	public void setCheckTime(Date checkTime) {
		this.checkTime = checkTime;
	}

	public YgUser getYgUser() {
		return ygUser;
	}

	public void setYgUser(YgUser ygUser) {
		this.ygUser = ygUser;
	}

	public UserType getUserType() {
		return userType;
	}

	public void setUserType(UserType userType) {
		this.userType = userType;
	}

	public String getCancelBy() {
		return cancelBy;
	}

	public void setCancelBy(String cancelBy) {
		this.cancelBy = cancelBy;
	}

	public Date getCancelTime() {
		return cancelTime;
	}

	public void setCancelTime(Date cancelTime) {
		this.cancelTime = cancelTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public String getUpdateBy() {
		return updateBy;
	}

	public void setUpdateBy(String updateBy) {
		this.updateBy = updateBy;
	}

	public Boolean inValidTime(Date time) {
		if (checkStatus.equals(CheckStatus.Pass) || checkStatus.equals(CheckStatus.WaitingCancel)) {
			if (time.after(checkTime)) {
				return true;
			}
		}
		if (checkStatus.equals(CheckStatus.Cancel)) {
			if (time.after(checkTime) && time.before(cancelTime)) {
				return true;
			}
		}

		return false;
	}

    public String getPlatformNo() {
        return platformNo;
    }

    public void setPlatformNo(String platformNo) {
        this.platformNo = platformNo;
    }

    public Long getLevelId() {
        return levelId;
    }

    public void setLevelId(Long levelId) {
        this.levelId = levelId;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

	public YgAgentLevel getAgentLevel() {
		return agentLevel;
	}

	public void setAgentLevel(YgAgentLevel agentLevel) {
		this.agentLevel = agentLevel;
	}

	@Override
	public YgAgent clone() {
		YgAgent ygAgent = null;
		try {
			ygAgent = (YgAgent) super.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return ygAgent;
	}

	public BigDecimal getLevelRate() {
		return agentLevel == null ? BigDecimal.ONE : agentLevel.getLevelRate();
	}
}